//
//  TabBarButton.m
//  HuiWenMovie
//
//  Created by niceDay on 15/7/17.
//  Copyright (c) 2015年 computer. All rights reserved.
//

#import "TabBarButton.h"

@implementation TabBarButton



- (instancetype)initWithFrame:(CGRect)frame withImageName:(NSString *)imageName withTitleName:(NSString *)title{
    self = [super initWithFrame:frame];
    if (self) {
        _imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        _imageView.contentMode = UIViewContentModeScaleAspectFit;
        
        _imageView.image = [UIImage imageNamed:imageName];
        
        [self addSubview:_imageView];
        
        _lable = [[UILabel alloc] initWithFrame:CGRectZero];
        _lable.text = title;
        _lable.textAlignment = NSTextAlignmentCenter;
        _lable.font = [UIFont systemFontOfSize:11];
        _lable.textColor = [UIColor whiteColor];
        
        [self addSubview:_lable];
    }
    return  self;
}
//当被加载到别的view上时
//宽高改变的时候
//  [set setNeedsLayout]
- (void)layoutSubviews{
    [super layoutSubviews];
//    CGRect rect = self.frame;
//    NSLog(@"%f",rect.size.height);
    _imageView.frame = CGRectMake((self.frame.size.width-20)/2, 5, 20, 20);
    _lable.frame = CGRectMake(0, CGRectGetMaxY(_imageView.frame), CGRectGetWidth(self.frame), 20);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
